﻿Public Class frmViewProSale

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        UI.FormatDataGrid(dgvproductlist)
        dgvproductlist.DataSource = Cmd.ExecuteDataTable("select i.item_id,qty,sell_out,i.item_name,i.photo from tbl_stock s inner join tbl_item i on i.item_id=s.item_id where i.active= true")
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Private Sub dgvproductlist_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgvproductlist.DoubleClick
        Dim row As DataGridViewRow

        If Not (dgvproductlist.SelectedRows.Count < 1) Then
            row = dgvproductlist.SelectedRows(0)
            frmSale.itemid = row.Cells("item_id").Value
            frmSale.txtitemname.Text = row.Cells("item").Value
            Dim s = row.Cells("price").Value.ToString
            frmSale.txtprice.Text = s.Substring(0, s.Length - 3)

            Dim bytes As Byte() = DirectCast(row.Cells("image").Value, Byte())
            Dim m As New System.IO.MemoryStream(bytes)
            frmSale.picitem.Image = New System.Drawing.Bitmap(m)
            frmSale.txtqty.Focus()
            frmSale.txtqty.SelectAll()
            Me.Close()
        End If
    End Sub
    Private Sub txtsearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.TextChanged

    End Sub
End Class